package adv7;

import java.io.*;
import java.net.*;
import java.util.Scanner;

public class TalkClient {
	// localhost表示本机
	public static void main(String[] args) {
		try {
			Socket s = new Socket("192.168.1.144", 6666);
			InputStream in = s.getInputStream();
			OutputStream out = s.getOutputStream();
			BufferedReader br = new BufferedReader(new InputStreamReader(in));
			PrintWriter pw = new PrintWriter(out, true);// 第二个参数，自动刷新
			Scanner sc = new Scanner(System.in);
			while (true) {
				System.out.println("please input:");
				String s1 = sc.nextLine();
				pw.println(s1);
				String str = br.readLine();
				System.out.println("服务器说：" + str);
				if (s1.equals("exit"))
					break;
			}
			s.close();
		} catch (Exception e) {
			// TODO 自动生成的 catch 块
			e.printStackTrace();
		}
	}

}
